home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / tutankhm.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  5KB  |  220 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9.  
  10. /*  Stuff that work only in MS DOS (Color cycling)
  11.  */
  12.  
  13. #include "driver.h"
  14. #include "vidhrdw/generic.h"
  15.  
  16.  
  17. unsigned char *tutankhm_scrollx;
  18. static int flipscreen[2];
  19.  
  20.  
  21.  
  22. static void videowrite(int offset,int data)
  23. {
  24.     unsigned char x1,x2,y1,y2;
  25.  
  26.  
  27.     x1 = ( offset & 0x7f ) << 1;
  28.     y1 = ( offset >> 7 );
  29.     x2 = x1 + 1;
  30.     y2 = y1;
  31.  
  32.     if (flipscreen[0])
  33.     {
  34.         x1 = 255 - x1;
  35.         x2 = 255 - x2;
  36.     }
  37.     if (flipscreen[1])
  38.     {
  39.         y1 = 255 - y1;
  40.         y2 = 255 - y2;
  41.     }
  42.  
  43.     plot_pixel(tmpbitmap,x1,y1,Machine->pens[data & 0x0f]);
  44.     plot_pixel(tmpbitmap,x2,y2,Machine->pens[data >> 4]);
  45. }
  46.  
  47.  
  48.  
  49. WRITE_HANDLER( tutankhm_videoram_w )
  50. {
  51.     videoram[offset] = data;
  52.     videowrite(offset,data);
  53. }
  54.  
  55.  
  56.  
  57. WRITE_HANDLER( tutankhm_flipscreen_w )
  58. {
  59.     if (flipscreen[offset] != (data & 1))
  60.     {
  61.         int offs;
  62.  
  63.  
  64.         flipscreen[offset] = data & 1;
  65.         /* refresh the display */
  66.         for (offs = 0;offs < videoram_size;offs++)
  67.             videowrite(offs,videoram[offs]);
  68.     }
  69. }
  70.  
  71.  
  72.  
  73. /***************************************************************************
  74.  
  75.   Draw the game screen in the given osd_bitmap.
  76.   Do NOT call osd_update_display() from this function, it will be called by
  77.   the main emulation engine.
  78.  
  79. ***************************************************************************/
  80. void tutankhm_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  81. {
  82.     if (palette_recalc())
  83.     {
  84.         int offs;
  85.  
  86.         for (offs = 0;offs < videoram_size;offs++)
  87.             tutankhm_videoram_w(offs,videoram[offs]);
  88.     }
  89.  
  90.     /* copy the temporary bitmap to the screen */
  91.     {
  92.         int scroll[32], i;
  93.  
  94.  
  95.         if (flipscreen[0])
  96.         {
  97.             for (i = 0;i < 8;i++)
  98.                 scroll[i] = 0;
  99.             for (i = 8;i < 32;i++)
  100.             {
  101.                 scroll[i] = -*tutankhm_scrollx;
  102.                 if (flipscreen[1]) scroll[i] = -scroll[i];
  103.             }
  104.         }
  105.         else
  106.         {
  107.             for (i = 0;i < 24;i++)
  108.             {
  109.                 scroll[i] = -*tutankhm_scrollx;
  110.                 if (flipscreen[1]) scroll[i] = -scroll[i];
  111.             }
  112.             for (i = 24;i < 32;i++)
  113.                 scroll[i] = 0;
  114.         }
  115.  
  116.         copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  117.     }
  118. }
  119.  
  120.  
  121.  
  122. /* Juno First Blitter Hardware emulation
  123.  
  124.     Juno First can blit a 16x16 graphics which comes from un-memory mapped graphics roms
  125.  
  126.     $8070->$8071 specifies the destination NIBBLE address
  127.     $8072->$8073 specifies the source NIBBLE address
  128.  
  129.     Depending on bit 0 of the source address either the source pixels will be copied to
  130.     the destination address, or a zero will be written.
  131.     This allows the game to quickly clear the sprites from the screen
  132.  
  133.     A lookup table is used to swap the source nibbles as they are the wrong way round in the
  134.     source data.
  135.  
  136.     Bugs -
  137.  
  138.         Currently only the even pixels will be written to. This is to speed up the blit routine
  139.         as it does not have to worry about shifting the source data.
  140.         This means that all destination X values will be rounded to even values.
  141.         In practice no one actaully notices this.
  142.  
  143.         The clear works properly.
  144. */
  145.  
  146. WRITE_HANDLER( junofrst_blitter_w )
  147. {
  148.     static unsigned char blitterdata[4];
  149.  
  150.  
  151.     blitterdata[offset] = data;
  152.  
  153.     /* Blitter is triggered by $8073 */
  154.     if (offset==3)
  155.     {
  156.         int i;
  157.         unsigned long srcaddress;
  158.         unsigned long destaddress;
  159.         unsigned char srcflag;
  160.         unsigned char destflag;
  161.         unsigned char *JunoBLTRom = memory_region(REGION_GFX1);
  162.  
  163.         srcaddress = (blitterdata[0x2]<<8) | (blitterdata[0x3]);
  164.         srcflag = srcaddress & 1;
  165.         srcaddress >>= 1;
  166.         srcaddress &= 0x7FFE;
  167.         destaddress = (blitterdata[0x0]<<8)  | (blitterdata[0x1]);
  168.  
  169.         destflag = destaddress & 1;
  170.  
  171.         destaddress >>= 1;
  172.         destaddress &= 0x7fff;
  173.  
  174.         if (srcflag) {
  175.             for (i=0;i<16;i++) {
  176.  
  177. #define JUNOBLITPIXEL(x)                                    \
  178.     if (JunoBLTRom[srcaddress+x])                            \
  179.         tutankhm_videoram_w( destaddress+x,                    \
  180.             ((JunoBLTRom[srcaddress+x] & 0xf0) >> 4)        \
  181.             | ((JunoBLTRom[srcaddress+x] & 0x0f) << 4));
  182.  
  183.                 JUNOBLITPIXEL(0);
  184.                 JUNOBLITPIXEL(1);
  185.                 JUNOBLITPIXEL(2);
  186.                 JUNOBLITPIXEL(3);
  187.                 JUNOBLITPIXEL(4);
  188.                 JUNOBLITPIXEL(5);
  189.                 JUNOBLITPIXEL(6);
  190.                 JUNOBLITPIXEL(7);
  191.  
  192.                 destaddress += 128;
  193.                 srcaddress += 8;
  194.             }
  195.         } else {
  196.             for (i=0;i<16;i++) {
  197.  
  198. #define JUNOCLEARPIXEL(x)                         \
  199.     if ((JunoBLTRom[srcaddress+x] & 0xF0))         \
  200.         tutankhm_videoram_w( destaddress+x,        \
  201.             videoram[destaddress+x] & 0xF0);    \
  202.     if ((JunoBLTRom[srcaddress+x] & 0x0F))        \
  203.         tutankhm_videoram_w( destaddress+x,        \
  204.             videoram[destaddress+x] & 0x0F);
  205.  
  206.                 JUNOCLEARPIXEL(0);
  207.                 JUNOCLEARPIXEL(1);
  208.                 JUNOCLEARPIXEL(2);
  209.                 JUNOCLEARPIXEL(3);
  210.                 JUNOCLEARPIXEL(4);
  211.                 JUNOCLEARPIXEL(5);
  212.                 JUNOCLEARPIXEL(6);
  213.                 JUNOCLEARPIXEL(7);
  214.                 destaddress += 128;
  215.                 srcaddress+= 8;
  216.             }
  217.         }
  218.     }
  219. }
  220.